package web;


import spring.cloud.tasks.client.Client;
import spring.cloud.tasks.client.item_task_processor.TaskProcessorInfo;
import spring.cloud.tasks.client.item_task_processor.Task;
import spring.cloud.tasks.client.item_task_processor.TaskItem;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

public class taskTypeInfo {
    public static void main(String[] args) throws Exception {
        HttpServletRequest request = null;
        String taskId = request.getParameter("$taskId");
        List<TaskProcessorInfo> schedulerInfoList = Client.getZooKeeperItemTaskDataManager().getTaskProcessorInfoList(taskId);
        for (int j = 0; j < schedulerInfoList.size(); j++) {
            String bgColor = "";
            Task task = Client.getZooKeeperItemTaskDataManager().loadTask(schedulerInfoList.get(j).getTaskId());
            if (schedulerInfoList.get(j).getCenterServerTime().getTime() - schedulerInfoList.get(j).getHeartBeatTime().getTime() > task.getJudgeDeadInterval()) {
                bgColor = "BGCOLOR='#A9A9A9'";
            } else if (schedulerInfoList.get(j).getLastFetchDataTime() == null || schedulerInfoList.get(j).getCenterServerTime().getTime() - schedulerInfoList.get(j).getLastFetchDataTime().getTime() > task.getHeartBeatRate() * 20) {
                bgColor = "BGCOLOR='#FF0000'";
            }

            System.out.println(schedulerInfoList.get(j).getProcessorId());

            System.out.println(schedulerInfoList.get(j).getIp());

            System.out.println(schedulerInfoList.get(j).getThreadNum());
            System.out.println(schedulerInfoList.get(j).getRegisterTime());
            System.out.println(schedulerInfoList.get(j).getHeartBeatTime());
            System.out.println(schedulerInfoList.get(j).getLastFetchDataTime());
            System.out.println(schedulerInfoList.get(j).getVersion());
            System.out.println(schedulerInfoList.get(j).getNextRunStartTime());

            System.out.println(schedulerInfoList.get(j).getMark());
            System.out.println(schedulerInfoList.get(j).getWorkerId());
        }
        List<TaskItem> taskItemAndParameterList = Client.getZooKeeperItemTaskDataManager().loadTaskItemList(taskId);
        for (int j = 0; j < taskItemAndParameterList.size(); j++) {
            System.out.println(taskItemAndParameterList.get(j).getTaskItemString());
            //System.out.println(taskItemList.get(j).getCurrentProcessorId());
            System.out.println(taskItemAndParameterList.get(j).getProcessorId());


            System.out.println(taskItemAndParameterList.get(j).getMark());
        }
    }
}
